home *** CD-ROM | disk | FTP | other *** search
- Path: chronicle.mti.sgi.com!news
- From: austern@isolde.mti.sgi.com (Matt Austern)
- Newsgroups: comp.lang.c++
- Subject: Re: Name-mangling standard
- Followup-To: comp.lang.c++
- Date: 12 Jan 1996 18:19:09 GMT
- Organization: SGI
- Message-ID: <AUSTERN.96Jan12101909@isolde.mti.sgi.com>
- References: <20c.32169.607@newage.com.ar> <4bsnbu$5mu@mujibur.inmind.com>
- <30EDC013.7C780E5E@cims.nyu.edu> <DL1pqE.KKq@infosoft.com>
- Reply-To: austern@mti.sgi.com
- NNTP-Posting-Host: isolde.mti.sgi.com
- In-reply-to: jgalt@infosoft.com's message of Fri, 12 Jan 1996 03:58:32 GMT
-
- In article <DL1pqE.KKq@infosoft.com> jgalt@infosoft.com (John Galt) writes:
-
- > I beg to differ. Name mangling serves several indispensible functions:
- >
- > 1. It makes it possible to have more than one function with the same name
- > (differing in their argument lists). To do this without mangling, the linker
- > would have to see not just a function name, or even class::name, but a full
- > _prototype_ for each function (omitting variable names and the result type).
- >
- > 2. It allows the linker to do error checking. Example: Module A calls
- > foo() in module B. I change the definition of foo (and its argument list)
- > but forget to change A. Without name mangling, the program will simply crash
- > (or do strange things because I've clobbered the stack...)
-
- But that's just an artifact of today's (or rather yesterday's) linker
- technology. Look at all the assumptions in those two paragraphs: that
- we're dealing with a compiler instead of an interpreter, that the
- compiler produces machine code instead of some intermediate-level
- description, that the only way to give a linker information about a
- function is through the function's name, and so on.
-
- Name mangling works, even though it's not very elegant, and it can be
- used with ordinary linkers; that's why most C++ compilers use it.
- There's nothing in the C++ standard, though, that mandates it.
- There's no reason why a C++ compilation system can't have a more
- sophisticated notion of what a linker is. More sophisticated linkers
- are probably a good idea anyway, because of templates.
-
- Name mangling is an implementation detail, and, moreover, a detail
- that only applies to certain kinds of implementations. It doesn't
- belong in the standard.
- --
- Matt Austern
- SGI: MTI Compilers Group
- austern@isolde.mti.sgi.com
-